package com.edison.service;



import com.edison.democommon.util.JWTUntil;
import com.edison.entity.User;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author edison
 */
@Service
public class AuthService {




    public Map<String,String> generateToken()
    {
        Map<String, Object> map = new HashMap<>(8);
        User currentUser = getUser();
        map.put("user", currentUser.getName());
        map.put("uid", currentUser.getId());
        // 15 s
        Map<String, String> tokenMap = new HashMap<>(2);
        tokenMap.put("token", JWTUntil.generateToken(map));

        return tokenMap;
    }

    /**
     *  query user mock  user
     */
    public User getUser()
    {
        User user = new User();
        user.setId(1);
        user.setName("edison");
        user.setEmail("edison@gmial.com");
        return user;
    }
}
